Skip to content

Fix pyright issue #30147 #30192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

sanleo-wq
Copy link

Description

This PR fixes issue #30147 by resolving the Pyright errors in the src/openvino/utils/types.py file.

Changes made

  • Added explicit cast import from the typing library
  • Updated as_node function to use proper type casting with isinstance checks instead of issubclass(type())
  • Fixed the return type in as_nodes function using cast for proper list typing

Testing

  • Removed src/openvino/utils/types.py from the exclusions in pyproject.toml
  • Ran Pyright which now reports no errors:

@sanleo-wq sanleo-wq requested a review from a team as a code owner April 17, 2025 14:07
@github-actions github-actions bot added the category: Python API OpenVINO Python bindings label Apr 17, 2025
@sys-openvino-ci sys-openvino-ci added the ExternalPR External contributor label Apr 17, 2025
@mlukasze
Copy link
Contributor

linter failed, please fix

@mlukasze mlukasze linked an issue Apr 18, 2025 that may be closed by this pull request

if np_type:
return np.dtype(np_type)
# Sostituita implementazione con next() per evitare None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comments, if necessary, should be in english, please


if np_type:
return np_type
# Sostituita implementazione con next() per evitare None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment language, please


raise OVTypeError("Unidentified data type %s", openvino_type)


def get_ndarray(data: NumericData) -> np.ndarray:
"""Wrap data into a numpy ndarray."""
if isinstance(data, np.ndarray):
return data # type: ignore
return data
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary change

return np.array(data)


def get_shape(data: NumericData) -> TensorShape:
"""Return a shape of NumericData."""
if isinstance(data, np.ndarray):
return data.shape # type: ignore
return data.shape
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary change

if isinstance(data, list):
return [len(data)] # type: ignore
return [len(data)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: Python API OpenVINO Python bindings ExternalPR External contributor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Good First Issue]: Fix pyright in: src/openvino/utils/types.py
3 participants